﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
 
namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string connectionString = "server=.;database=dbtest;uid=sa;pwd=123456";

            SqlConnection sqlConnection = new SqlConnection(connectionString);

            sqlConnection.Open();

            var sqlCommandString = "select * from commodity";

            SqlCommand sqlCommand = new SqlCommand(sqlCommandString, sqlConnection);

            var sdr = sqlCommand.ExecuteReader();

            Console.WriteLine("{0}\t\t{1}\t\t\t{2}\t\t{3}", "commodityId", "commodityName", "FactoryId", "genreId");

            while (sdr.Read())
            {
                Console.WriteLine("{0}\t\t\t{1}\t\t\t{2}\t\t\t{3}", sdr["commodityId"], sdr["commodityName"],sdr["FactoryId"],sdr["genreId"]);

            }

            sqlConnection.Close();
        }
    }
}
